.form-group
  = form.label :name
  = form.text_field :name, onkeyup: 'set_last_name()', class: 'form-control'
  - if @family.new_record?
    .family-name-suggestion
      = t('families.edit.name_example_html')
  - elsif @family.suggest_name?
    .family-name-suggestion
      = t('families.edit.name_suggestion_html', name: @family.suggested_name)
      = link_to '#', class: 'btn btn-xs btn-warning family-name-suggestion-button', data: { name: @family.suggested_name } do
        = icon 'fa fa-bolt'
        = t('families.edit.name_suggestion_button')
.form-group
  = form.label :last_name
  = form.text_field :last_name, class: 'form-control'
= render partial: 'families/phone_and_address_fields', locals: { form: form }

:javascript
  function set_last_name() {
    var parts = $('#family_name').val().split(' ');
    $('#family_last_name').val(parts.length > 1 ? parts[parts.length-1] : '');
  }
